{smcl}
{* 24aug2016}{...}
{cmd:help rdperm}{right:version:  4.0.0}
{hline}

{title:Title}

{p 4 8}{cmd:rdperm}  -  Canay and Kamat (2017) procedure{p_end}


{title:Syntax}

{p 4 6 2}
{cmdab:rdperm}
{varlist}
{ifin}
[, {opt c:utoff(#)} {opt q:observations(#)} {opt p:ermutations(#)} {opt cvm}]


{title:Notes}

{p 4 6 2}
- First variable in the {varlist} is the running variable and the remaining are covariates.{p_end}


{title:Description}

{p 4 4 2}
{opt rdperm} provides a procedure for testing the null hypothesis of continuity of the distribution of baseline covariates at the cutoff in 
the regression discontinuity design (RDD). It implements the permutation test procedure outlined in Canay and Kamat (2017).{p_end}


{title:Options}

{phang}
{opt c:utoff(#)} specifies the cutoff or threshold value in the RDD treatment rule. The default is c(0).

{phang}
{opt q:observations(#)} specifies the number of effective observations used from either side of the cutoff, which are those with running variable values closest to the cutoff. The rule of thumb option is set by q(0), referring to footnote 4 in           Canay and Kamat (2017), or by q(-1), referring to equation 15 in Canay and Kamat (2017). The default is q(0).

{phang}
{opt p:ermutations(#)} specifies the number of random permutations performed to obtain the critical value. This must take a positive integer value. The default is p(999).

{phang}
{opt cvm} specifies whether the cvm test statistic is used in the joint test with multiple covariates. If this option is omitted then the max test statistic, as described in Canay and Kamat (2017), is used by default. Note that with a single 
covariate these two test statistics are identical.


{title:Example}

{phang}Load dataset from Lee (2008).{p_end}
{phang}{stata "use table_two_final.dta" : . use table_two_final.dta}{p_end}

{phang}Implement test with default options.{p_end}
{phang}{stata "rdperm difdemshare demshareprev" : . rdperm difdemshare demshareprev}{p_end}

{phang}Implement joint test using 50 observations from either side.{p_end}
{phang}{stata "rdperm difdemshare demshareprev demwinprev, q(50)" : . rdperm difdemshare demshareprev demwinprev, q(50)}{p_end}


{title:Stored Results}

{cmd:rdperm} stores the following in {cmd:r()}:

{synoptset 20 tabbed}{...}
{syntab:Scalars:}
{synopt:{cmd:r(c)}}cutoff value{p_end}
{synopt:{cmd:r(q)}}effective number of observations used from either side of cutoff{p_end}
{synopt:{cmd:r(P)}}number of permutations{p_end}
{synopt:{cmd:r(N)}}number of observations{p_end}
{synopt:{cmd:r(N_l)}}number of observations to the left of cutoff{p_end}
{synopt:{cmd:r(N_r)}}number of observations to the right of cutoff{p_end}
{synopt:{cmd:r(h_l)}}effective neighbourhood of observations to the left of cutoff{p_end}
{synopt:{cmd:r(h_r)}}effective neighbourhood of observations to the right of cutoff{p_end}
{synopt:{cmd:r(pval)}}p-value obtained{p_end}

{syntab:Macros:}
{synopt:{cmd:r(runningvar)}}running variable used{p_end}
{synopt:{cmd:r(covariates)}}covariates used{p_end}
{synopt:{cmd:r(teststat)}}test statistic used{p_end}
{synopt:{cmd:r(cmd)}}{cmd:rdperm}{p_end}
{synoptline}


{title:References}

{p 4 6 2}
 - Canay, I.A. and Kamat, V. (2017). Approximate Permutation Tests and Induced Order Statistics in the Regression Discontinuity Design. CeMMAP working paper CWP33/16.{p_end}

{p 4 6 2}
 - Lee, D. S. (2008). Randomized experiments from non-random selection in U.S. House elections. Journal of Econometrics, 142 675-697.{p_end}


{title:Authors}

{p 4 4}Ivan A. Canay, Northwestern University, iacanay@northwestern.edu{p_end}

{p 4 4}Vishal Kamat, Northwestern University, v.kamat@u.northwestern.edu{p_end}


